package com.gluck.cases.boostrap.controller;

import com.gluck.cases.common.utils.constants.BizSerConstant;
import com.gluck.cases.common.utils.utils.BizResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName FilterController
 * @Desc Filter 异常统一输出
 * @Author I am Gluck
 * @Date 2022/5/18 - 5:18 下午
 **/
@RestController
@RequestMapping(value = "/error", name = "Filter 异常统一输出")
public class FilterController {

    /**
     * 功能描述: 拦截器异常输出接口
     * @Params [request]
     * @Return com.gluck.stock.base.utils.BizResult
     * @Author I`m Gluck
     * @Date 2022/5/23
     */
    @RequestMapping(value = "/throws", method = RequestMethod.GET, name = "拦截器异常输出接口")
    public BizResult throwsError(HttpServletRequest request){
        String code = request.getAttribute(BizSerConstant.ERROR_CODE).toString();
        String msg = request.getAttribute(BizSerConstant.ERROR_MSG).toString();
        return BizResult.newFailResult(code, msg);
    }
}
